DEFINITION MODULE Windows;

  FROM SYSTEM IMPORT BYTE;

  TYPE
    BorderType  = (Double, Single, NoBorder);
    OldDataType = ARRAY [0..3999] OF BYTE;
    FRAME       = RECORD
                    TopRow,
                    TopCol,
                    BottomRow,
                    BottomCol,
                    BAttribute,
                    WAttribute : CARDINAL;
                    WBorder    : BorderType;
                    OldData    : OldDataType;
                    Open       : BOOLEAN;
                  END;



  PROCEDURE CreateWindow (VAR Window   : FRAME;
                              TRow,
                              TCol,
                              BRow,
                              BCol     : CARDINAL;
                              Border   : BorderType;
                              BAttrib,
                              WAttrib  : CARDINAL);

    (*  A new window is created at position (TopRow,TopCol), where the origin
        is (0,0).

        WAttrib is the background attribute for the window.  Used especially
        when clearing the window, as a reverse clear might be required.

        If a border is not required then `NoBorder' should be entered, also,
        `Blank' attribute should be entered for the border attribute (BAttrib).
        Otherwise select either `Single' or `Double' for the border with the
        appropriate attribute. *)


  PROCEDURE CloseWindow (VAR Window : FRAME);

    (*  This procedure closes down a window and restores the old data to the
        screen.

        It should be noted that in order for this to work properly, all the
        open windows should be closed in reverse order to them being opened *)


  PROCEDURE ClearWindow (VAR Window  : FRAME;
                             Pattern : CHAR);

    (*  The selected window will be cleared.  The attribute of the clear is the
        one selected in the window definition.
        The area selected is the area inside the border.  If no border is
        displayed, it should be imagined that there is one. *)


  PROCEDURE WindowAt (VAR Window : FRAME;
                          Row,
			  Col    : CARDINAL);

    (*  Positions the cursor at (Row,Col) relative to the (0,0) position of the
        top left hand corner of the selected window *)


  PROCEDURE WriteStringWrapAt (VAR Window : FRAME;
                                   Row,
                                   Col    : CARDINAL;
                                   String : ARRAY OF CHAR);

    (*  This procedure will display a string at a local location in a window.
        The top lefthand corner of the display area is (1,1).  Should there be
        no border then the position (0,0) may be used.

        The text will wrap around to the next line should it exceed the line
        length.  Words are not split.  Should a word be broken by the end of
        the line, it is written on the next line.

        Should the string pass beyond the bottom of the window, it is not all
        displayed.

        Any attributes required for the text displayed should be set from
        the ScreenHandler module.

        e.g. to display text in Bold, you should import SetBold *)


  PROCEDURE WriteStringAt (VAR Window : FRAME;
                               Row,
                               Col    : CARDINAL;
                               String : ARRAY OF CHAR);

    (* Writes string at position (Row, Col) in Window *)


  PROCEDURE WriteCharAt (VAR Window : FRAME;
                             Row,
                             Col    : CARDINAL;
                             Char   : CHAR);

    (* Writes character Char at position (Row, Col) in Window *)



  PROCEDURE WriteStringCentre (VAR Window : FRAME;
                                   Row    : CARDINAL;
                                   String : ARRAY OF CHAR);

    (* The same attribute conditions also apply as for WriteStringAt *)


  PROCEDURE WriteCentreExSpaces (VAR Window : FRAME;
                                     Row    : CARDINAL;
                                     String : ARRAY OF CHAR);

    (*  Same a WriteStringCentre except no spaces are displayed before and
        after the string. *)


  PROCEDURE WriteTitle (VAR Window : FRAME;
                            Row    : CARDINAL;
                            String : ARRAY OF CHAR);

    (* The same attribute conditions also apply as for WriteStringAt *)


  PROCEDURE WriteCardAt (VAR Window : FRAME;
                             Row,
                             Col,
                             Card,
                             Width  : CARDINAL);

    (*  This procedure will write a cardinal at (Row, Col) in the selected
        window - similar to WriteCard from InOut *)


  PROCEDURE WriteIntAt (VAR Window : FRAME;
                            Row,
                            Col    : CARDINAL;
                            Int    : INTEGER;
                            Width  : CARDINAL);

    (*  This procedure will write an integer at (Row, Col) in the selected
        window *)


  PROCEDURE WriteLongIntAt (VAR Window  : FRAME;
                                Row,
                                Col     : CARDINAL;
                                LongInt : LONGINT;
                                Width   : CARDINAL);

    (*  This procedure will write a LONGINT at (Row, Col) in the selected
        window *)


END Windows.